Cannot compare type Timestamp with type str

by: tejaswagh, 7 years ago


in the very introductory tutorial of machine learning(https://pythonprogramming.net/regression-introduction-machine-learning-tutorial/), im getting the error 'Cannot compare type 'Timestamp' with type 'str'' on the line:
df['PCT_change'] = (df['Adj. Close'] - df['Adj. Open']) / df['Adj. Open'] * 100.0
what should i do resolve it?



You must be logged in to post. Please login or register an account.



I ran into a similar issue as tejaswagh. Checked the comments under the video. Anyone else running into a similar error, try making your completed example look like this:

import pandas as pd
import quandl as qq

qq.ApiConfig.api_key = "[your_api_key]"
df = qq.get("WIKI/GOOGL")

df = df[['Adj. Open', 'Adj. High', 'Adj. Low', 'Adj. Close', 'Adj. Volume']]
df['HL_PCT'] = (df['Adj. High'] - df['Adj. Low']) / df['Adj. Low'] * 100.0
df['PCT_change'] = (df['Adj. Low'] - df['Adj. High']) / df['Adj. High'] * 100.0

df = df[['Adj. Close', 'HL_PCT', 'PCT_change', 'Adj. Volume']]

print(df.head())


-pynub 5 years ago
Last edited 5 years ago

You must be logged in to post. Please login or register an account.